home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_070 / logo / logo.doc < prev    next >
Text File  |  1992-05-06  |  19KB  |  583 lines

  1.     ALOGO - © 1986 by Gerald Owens
  2.  
  3.     Permission is given for free, non-commercial distribution.
  4. This software is TRUE shareware:  If you have contributed something
  5. to the public domain, then you can keep it for free!  Otherwise, it is
  6. requested that you send a tax deductible donation of $5.00 to:
  7.  
  8.                Wycliffe Associates
  9.                Box 2000
  10.                Orange, Ca.   92669-9984
  11.  
  12.  
  13.     Specify that the money is to go for literacy training in less
  14. developed countries, and tell them that "S" sent you.  Be sure to tell
  15. them not to send further information if you don't want it.
  16. Please direct all bug reports and suggestions for improvements to:
  17.  
  18.                Gerald Owens                   Gerald Owens
  19.                C/O William Richardson         C/O Amiga Atlanta
  20.                1599 Council Bluff Dr.         Box 7724
  21.                Atlanta, Ga.  30345            Atlanta, Ga.  30357
  22.  
  23.  
  24. LIMITATIONS
  25.  
  26.      This is just the graphics portions of LOGO.  I have tried to
  27. follow the Apple II LOGO commands as closely as possible, with the
  28. exception of file, editor, and printer related commands.  Any good
  29. book on LOGO should be of help.
  30.  
  31.  
  32. PROBLEM AREAS
  33.  
  34.      A single window is used for the editor, command, and graphics
  35. window.  Wierd things happen to the "turtle" when things get scrolled.
  36.  
  37.      Do not panic!  Repeat, do NOT panic if after successfully executing
  38. a procedure, you re-edit the buffer and find a blank screen!  The
  39. editor is fixed to place the cursor in front of the NEXT statement
  40. to be executed.  If there is an error, the cursor will be in front
  41. of the offending statement.  When a procedure returns, the cursor
  42. is temporarily placed after the END or the OUTPUT statement, so if
  43. the last procedure executed was the last procedure in the editor
  44. buffer, the cursor will be placed after the END statement, and so
  45. may appear alone on a blank screen.  Just press SHIFT-UP ARROW to
  46. get to your code.
  47.  
  48.      The editor is not very good.  I hope that if a later version comes
  49. out, it will be worthy of alternate use as a programmer's editor.
  50.  
  51.      The program polls the window message port constantly for a keypress
  52. while it executes, so that it can stop at a keypress.  Unfortunately,
  53. this takes up so much CPU time that it is virtually unable to be
  54. multi-processed.  My apologies.  I'm sure there's a work-around, but
  55. the Amiga is such a complicated machine that it will probably take a
  56. while for me to get sophisticated enough to implement it in assembler.
  57.  
  58.      There are no global variables.  All procedure variables are
  59. sort of local/global.  They're global in the sense that they are
  60. accessible outside of the procedure, and local in the sense that
  61. when a procedure is entered, the old value is saved, and when the
  62. procedure is exited, the old value is restored.  Every unique variable
  63. name is placed in a table and all accesses refer to that central
  64. copy, so the scope can be classified as being dynamic.  If you want
  65. global variables, declare a dummy procedure with "local" variables
  66. having the names of the desired global variables.
  67.  
  68.      Procedures and variables are declared using the editor.  They
  69. cannot be declared from the command processor.  When declaring a
  70. procedure, the header (TO <name> <vars>) MUST START on separate lines.
  71.  
  72.  
  73. HOW TO RUN
  74.      ALOGO cannot be executed from the Workbench.  Rather, get into the
  75. CLI and type in:
  76.  
  77. logo
  78.  
  79.            
  80.  
  81. GENERAL COMMANDS
  82.  
  83.    These commands are in addition to the regular ALOGO commands, but
  84. only one command can be typed in on a line.
  85.  
  86. NEW
  87.    Clear the editor buffer.  Will prompt if contents have been
  88.    changed and not saved.
  89.  
  90. LOAD filename
  91.    Clears the editor buffer and loads the text file into the
  92.    editor buffer.  If the previous contents of the buffer was
  93.    changed and not saved, the computer will ask if it is OK
  94.    to delete the file.
  95.    ***WARNING*** Do not use a file name with an embedded blank.
  96.                  Even if it has ""'s around it!
  97.  
  98. SAVE
  99.    Without a file name, saves the editor buffer with the same
  100. name as it was previously loaded or saved under.
  101.  
  102.  
  103. SAVE filename
  104.    Saves the editor buffer under the new name, and records it so that
  105. "SAVE" without a file name saves under that file name.
  106.  
  107.  
  108. EDIT
  109.    Edit the editor buffer.  Press function key 'F1' to excape from the
  110. editor
  111.  
  112.  
  113. LIST
  114.    List the contents of the editor buffer on the screen.  Pressthe Right
  115. Mouse Button to temporarily stop the listing, and release it to
  116. allow the listing to continue.
  117.  
  118.  
  119. LLIST
  120.    Same as LIST, but the contents of the editor buffer are printed
  121. on the printer attached to your Amiga, followed by a Page-Eject.
  122.  
  123.  
  124. FILES
  125.    Same as the AmigaBASIC "FILES" command.  Lists the files in the
  126. current directory on the screen.  Requires that the "DIR" command be
  127. in the "C:" directory.
  128.  
  129.  
  130. QUIT
  131.    Leave logo and return to the operating system.
  132.  
  133.  
  134.  
  135. EDITOR COMMANDS
  136.    Use the cursor keys to move up, down, left, and right.
  137.    Shift up-cursor moves the cursor up 10 lines.
  138.    Shift down-cursor moves the cursor down 10 lines.
  139.    Shift left-cursor move the cursor to the beginning of the line.
  140.    Shift right-cursor moves the cursor to the end of the line.
  141.    The grey DEL key deletes the character under the cursor.
  142.    The BACKSPACE key deletes the character just before the cursor.
  143.    Shift DEL key deletes an entire line.
  144.    Press RETURN to get a new line, or make a line into two lines.  Sorry,
  145.       no way to join two lines together as yet.
  146.    CTRL-Q, CTRL-X and F1 exits from the editor.
  147.  
  148.  
  149.  
  150. EXPRESSIONS
  151.    An element can be any of the following:
  152.  
  153.    a.  A signed integer number (32 bits).  (-235, 447)
  154.    b.  A built-in variable.  (XCOR, YCOR, HEADING, and PENCOLOR.)
  155.    c.  A procedure call.  See the ALOGO command "OUTPUT" on how to
  156.        make a procedure return a value.  (COORD, FAC 4, DDT 77+2 99.)
  157.    d.  A user defined variable.  These start with a ":", followed by
  158.        a letter, and then followed by an optional sequence of letters
  159.        and digits.  (:a , :a1e2b4, :zzz).
  160.    
  161.    (As in the rest of ALOGO, it does not matter if the letters are
  162. in upper or lower case.  Thus, xcor, XCOR, and XcOr are all the same.)
  163.  
  164.    An expression is an element or an algebraic expression using elements.
  165. The following are valid expressions:
  166.  
  167.    5
  168.    :a+5
  169.    3*(:a-7)
  170.    :z/-9+ fac 6    (Procedure call of fac 6.  Result is added to :z/-9)
  171.    :Q % 6          (Remainder of :Q divided by 6)
  172.    -:r             (Negative of the value of :r)
  173.    xpos+4          (The value of built-in variable xpos has 4
  174.                     added to it)
  175.  
  176.    The following are valid operators to use in an expression.  They
  177. all behave the same as they do in AmigaBASIC.
  178.  
  179.    <  -  Less than, for comparing two numbers.
  180.    =  -  Equal to, for comparing two numbers.
  181.    >  -  Greater than, for comparing two numbers.
  182.    AND - Logical AND.
  183.    OR -  Logical OR.
  184.    NOT - Logical NOT.
  185.    *  -  Multiplication
  186.    /  -  Division
  187.    %  -  Modulo.  Same as MOD in AmigaBASIC.
  188.    +  -  Addition
  189.    -  -  Subtraction and negation.
  190.  
  191.    The precedence is as follows (same as for BASIC)
  192.  
  193.    ()'s        (To change the order of the precedence)
  194.    -           (Negation.)
  195.    * , / , %   (Same precedence.  Done left to right.  So 2*3*5/6 is
  196.                 (((2*3)*5)/6). )
  197.    + , -       (Same precedence.  Also done left to right.)
  198.    <,=,>       (Note:  <=,=>, and <> are NOT permitted.)
  199.    NOT
  200.    AND         (Done left to right.)
  201.    OR          (Done left to right.)
  202.  
  203.    Remember that ALOGO does not use anything to separate different
  204. expressions.  This can cause problems when using negation.
  205. As an example, if it is desired to print out 1 and -1 on the
  206. same line, the following command will NOT work:
  207.  
  208.    PRINT [1 -1]
  209.  
  210. It will print out 0, since 1-1 is 0.  To get 1 and -1 to be printed
  211. out separately, one must use:
  212.  
  213.    PRINT [1 (-1)]
  214.  
  215.  
  216.  
  217. ALOGO BUILT-IN VARIABLES
  218.  
  219.    The following are the ALOGO built-in variables.  They hold the values
  220. of different aspects of the drawing pen.
  221.  
  222.  
  223. XCOR
  224.  
  225.    Holds the horizontal coordinate of the pen.  It will normally range
  226. from 0 to 610 in value.  0 is for the far left of the window, and
  227. 610 is for the far right of the window.
  228.  
  229.  
  230. YCOR
  231.  
  232.    Holds the vertical coordinate of the pen.  It will normally range
  233. from 0 to 182 in value, 0 is for the top of the window, and 182 is
  234. for the bottom of the window.
  235.  
  236.  
  237. HEADING
  238.  
  239.    Holds the heading of the pen, which is the direction in which the
  240. pen will move if given a FORWARD or BACK command.  It will range in
  241. value from 0 to 359.
  242.  
  243.  
  244. PENCOLOR
  245.  
  246.    Holds the present drawing color of the pen.  This will be a value
  247. from 0 to 3.  The exact color drawn will depend on the colors set in
  248. the preferences menu.
  249.  
  250.  
  251.  
  252. ALOGO COMMENTS
  253.  
  254.    All ALOGO comments start with a ';', and continue to the end of the
  255. line, and can appear in any line.  For example:
  256.  
  257.          CS PD FD 10 ; this will not be executed >> LT 90 FD 10
  258.  
  259. will draw a line 10 steps long, but will not add the second line going
  260. to the left at the end of the first line.
  261.  
  262.  
  263. ALOGO COMMANDS
  264.  
  265.    The following commands can be typed in at the '>' prompt.  More
  266. than one command can be typed in on the same line.  To stop execution
  267. of the commands or any procedures, press a key on the Amiga keyboard.
  268.  
  269.    The words 'exp', 'exp1', 'exp2', and 'exp3' represent valid expressions
  270. as outlined above.  If none of these appear in the command, then the
  271. command does not take any parameters.
  272.  
  273.    Some of the commands can take a 2 letter abbreviation.  They can also
  274. be typed in in any mix of upper and lower case letters.
  275.  
  276.  
  277. CS
  278. CLEARSCREEN
  279.  
  280.    Clear the screen, put the drawing pen at the center of the screen,
  281. and set the direction to 0 degrees (up).  The pen is left up or down.
  282.  
  283.  
  284. HOME
  285.  
  286.    Put the drawing pen at the center of the screen and set the direction
  287. to 0 degrees (up).  The pen is left either up or down.
  288.  
  289.  
  290. CLEAN
  291.  
  292.    Just clear the screen, without affecting the pen location or whether
  293. the pen is up or down.
  294.  
  295.  
  296. PU
  297. PENUP
  298.  
  299.    Reset the pen so that the pen will not draw lines when moved.
  300.  
  301.  
  302. PD
  303. PENDOWN
  304.  
  305.    Set the Pen so that if the pen is moved, lines will be drawn.
  306.  
  307.  
  308. SETPC exp
  309.  
  310.    Set the pen color to the value of (exp % 4).  Pen colors are dependent
  311. on the Preferences settings, but they will map to the following colors
  312. on all screens:
  313.  
  314.             0 - Background color.
  315.             1 - Color of the letters and the border.
  316.             2 - Color of the Depth Arranger gadget in the upper
  317.                 right corner of the window.
  318.             3 - Color of the cursor.
  319.  
  320.  
  321. SETPOS [exp1 exp2]
  322.  
  323.    Set the pen to be at horizontal coordinate exp1, and vertical coordinate
  324. exp2.  (0,0) is at the upper left corner of the outside of the window, and
  325. (610,182) is at the lower right corner of the window.  If the pen is
  326. down, a line is drawn from the previous position to the new position.
  327. THE "[]"'S AROUND THE TWO EXPRESSIONS ARE MANDATORY.
  328.  
  329.  
  330. DOT [exp1 exp2]
  331.  
  332.    Places a dot of the present pen color at horizontal coordinate exp1
  333. and vertical coordinate exp2.  Exp1 can range from 0 to 610, and exp2
  334. can range from 0 to 182.  THE "[]"'s AROUND THE
  335. TWO EXPRESSIONS ARE MANDATORY.
  336.  
  337.  
  338. SETX exp
  339.  
  340.    Like SETPOS, but sets the horizontal coordinate only, leaving the
  341. vertical coordinate alone.  If the pen is down, then a line is drawn to
  342. the new position from the old position.
  343.  
  344.  
  345. SETY exp
  346.  
  347.    Like SETPOS and SETX, but sets the vertical coordinate only, leaving
  348. the horizontal coordinate alone.  If the pen is down, then a line is drawn
  349. to the new position from the old position.
  350.  
  351.  
  352. FD exp
  353. FORWARD exp
  354.  
  355.    Move in the direction of the heading of the pen (exp) many 'steps'.
  356. (There are 182 steps vertically and 304 horizontally.)  If the pen
  357. is down draw a line.  Note from SETPOS that a step in the horizontal
  358. direction is doubled.  This makes the aspect ratio close to 1:1, so
  359. that the logo statements "FD 10 LT 90 FD 10 LT 90 FD 10 LT 90 FD 10"
  360. forms more of a square than a rectangle.
  361.  
  362.  
  363. BK exp
  364. BACK exp
  365.  
  366.    Move in the opposite direction of the heading of the pen (exp)
  367. many 'steps'.  BK exp is the same as FD -(exp).
  368.  
  369.  
  370. LT exp
  371. LEFT exp
  372.  
  373.    Turn the heading of the pen's heading left (exp) degrees.  Directions
  374. on the screen are:
  375.  
  376.                    left   right
  377.                    <---   --->
  378.                         0
  379.                         ^
  380.                         |
  381.                   270 <-+-> 90
  382.                         |
  383.                         V
  384.                        180
  385.                    <---   --->
  386.                   right   left
  387.  
  388.  
  389. RT exp
  390. RIGHT exp
  391.  
  392.    Turn the heading of the pen's heading right (exp) degrees.  See the
  393. entry for LT and LEFT.   RT exp is the same as LT -(exp)
  394.  
  395.  
  396. SETH exp
  397. SETHEADING
  398.  
  399.    Turn the heading of the pen to the heading of (exp) degrees.  See the
  400. entry for LT and LEFT to see the directions to which the heading will
  401. translate.
  402.  
  403.  
  404. PRINT [ {exp | 'string'} {exp | 'string'} . . . ]
  405.  
  406.     Print the strings or the values of the expressions between the
  407. '[' and the ']'.  There can be as many expressions or as many strings,
  408. in any order, as you wish between the '[' and the ']'.  Strings
  409. *MUST* be surrounded by "'"'s.  The following lines print out
  410. various values.  The results are shown.
  411.  
  412.          PRINT [ 45*7 ' is 315']
  413. result:315  is 315
  414.  
  415.          PRINT ['this' ' is ' 'a' 'test']
  416. result:this is atest                   (put 'a ', rather than 'a', to
  417.                                         avoid this.)
  418.  
  419.          print [1*2 2*2 2*4]
  420. result:2 4 8
  421.  
  422.          PRINT [1*2 '+' 2*3 '=' 2*4]
  423. result:2 +6 =8
  424.  
  425.  
  426. MAKE "var exp
  427.  
  428.    Changes the value of the procedure variable to be the same as exp.
  429. Thus, if the value of :xxt is 17, then executing:
  430.  
  431.    MAKE "xxt :xxt+5
  432.  
  433. will change the value of :xxt to 22.  Note that the ":" is replaced
  434. by a double quote, which is required.  The values of built-in variables
  435. cannot be changed using MAKE.
  436.  
  437.  
  438.  
  439. ALOGO CONTROL STATEMENTS
  440.  
  441.    The following statements affect the flow of control of the program.
  442. Only TO and END can be used in an editor buffer.  All the others can be
  443. typed in directly at the '>' prompt, and in the editor buffer.
  444.  
  445.  
  446. RP exp [stmt stmt ....]
  447. REPEAT exp [stmt stmt ....]
  448.  
  449.    Repeat all the statements between the '[' and the ']' (exp) times.
  450. If exp is less than or equal to 0, the statements between the '[]''s
  451. are not executed.  The following two lines draw the same squares.
  452.  
  453.          CS PD FD 40 LT 90 FD 40 LT 90 FD 40 LT 90 FD 40 LT 90
  454.  
  455.          CS PD REPEAT 4 [FD 40 LT 90]
  456.  
  457.    THE "[]"'s ARE REQUIRED.
  458.  
  459.  
  460. IF exp [true statements] [false statements]
  461. IF exp [true statements]
  462.  
  463.    Tests the value of exp, and if true (not zero) all the statements
  464. between the first set of "[]"'s will be true.  If a second set of
  465. statements are between "[]"'s and are after the first set, they are
  466. skipped.  If the value of exp is false (zero), then the first set
  467. of statements between the "[]"'s is skipped, and the second set of
  468. statements between the second pair of "[]"'s is executed.  If a second
  469. set of statements does not exist (as in the second IF statement), then
  470. there is no error.  There IS an error if the "[]"'s are missing, or
  471. if there is no first set of statements.
  472.  
  473.  
  474. TO procedurename :variable :variable ....
  475. .
  476. .
  477. END
  478.  
  479.    Define a procedure named procedurename, with the variables after it
  480. as parameters.  Procedures cannot be defined directly, but must be typed
  481. into the editor buffer.
  482.  
  483.    TO *MUST* be at the beginning of the line, but END does not have to be on
  484. it's own line.  Failure to do so will cause ALOGO to complain that a
  485. procedure has not been defined.
  486.  
  487.    When the procedurename and parameters are typed in (using the same syntax
  488. as all the built-in commandss), all the statements between the TO and the
  489. END will be executed.
  490.  
  491.    ALOGO variables begin with a ':' followed by a letter, and can be
  492. composed of letters and digits.  ALOGO will not distinguish between
  493. upper and lower case letters, either in the procedure name or the
  494. variable names.
  495.  
  496.    Examples:
  497. ((these are typed into the editor buffer))
  498.  
  499.       to square :x  ;draw a square :x units on a side.
  500.          FD :x LT 90 FD :x LT 90 FD :x LT 90 FD :x LT 90
  501.       end
  502.  
  503.       to multisquare :x1 :turn :x   ;draw :x squares :x1 units on a side
  504.                                     ;turning :turn degrees between each
  505.                                     ;drawn square.
  506.          RP :x [square :x1 LT :turn]  ; this :x will not be confused with
  507.                                       ; the :x in square.  They are
  508.                                       ; different variables.
  509.       end
  510.  
  511. ((these are typed in at the '>' prompt))
  512.  
  513.      >square 50             ;draws a square 50 units on a side
  514.      >multisquare 30 10 36  ;draws 36 squares that are 30 units on a side
  515.                             ;turning 10 degrees between each square
  516.  
  517.    Trying to execute a procedure that is not defined in the editor buffer
  518. will cause ALOGO to complain.
  519.  
  520.    ALOGO procedures are like AmigaBASIC subroutines, and do not normally
  521. return a value.  To make a procedure return a value, so that it can be
  522. used in an expression, see the "OUTPUT" statement.
  523.  
  524.    ALOGO procedures can call other procedures, and can even call
  525. themselves.
  526.  
  527.  
  528. OUTPUT  exp
  529.  
  530.    To make a procedure return a value, use the OUTPUT statement.  The
  531. value returned will be the value of exp.  Some examples are:
  532.  
  533.    ((The following lines are typed into the Editor Buffer))
  534.  
  535.    to sum3 :x :y :z            ;return the sum of :x, :y, :z
  536.       output :x+:y+:z
  537.    end
  538.  
  539.    ((the following lines are typed at the ">" prompt.))
  540.  
  541.    >print [5*sum3 1 2 3]       ;do 5*(1+2+3)
  542. 30
  543.  
  544.    >print [sum3 1 2 3]         ;do 1+2+3
  545. 6
  546.  
  547.    The OUTPUT statement can be used anywhere, even in a set of statements
  548. between "[]"'s in the IF and REPEAT statements.  The execution of the
  549. IF or the REPEAT will be terminated, and the value returned to the
  550. procedure that called the procedure.  It is sort of like the AmigaBASIC
  551. RETURN statement.
  552.  
  553.  
  554. STOP
  555.  
  556.    Like the OUTPUT statement, the STOP statement stops the execution
  557. of a procedure and returns to the procedure that called the original
  558. procedure.  It is exactly like the AmigaBASIC RETURN statement.
  559.  
  560.  
  561. HALT
  562.  
  563.    This is like the AmigaBASIC STOP statement.  It stops the execution
  564. of all procedures and returns to the ">" prompt.  Pressing a key on
  565. the Amiga keyboard will have the same effect.
  566.  
  567.  
  568.  
  569.  
  570. FINAL NOTES
  571.  
  572.      ALOGO V1.0 is written entirely in assembly language, which
  573. accounts partly for its speed and partly for its rough edges, since
  574. most of the programming examples provided by Commodore are oriented
  575. towards "C".  The headers of the procedures are partly compiled into
  576. a table for quick lookup, and are tied directly to the source code
  577. in the editor.  Changing a line in the editor forces this table to
  578. be recompiled.  I could have compiled all the procedures in the
  579. editor buffer in their entirety, but there would have been no direct
  580. connection between errors in the compiled code and where the error
  581. was located in the source.  Thus, in a child-oriented language, I opted
  582. for making the location of errors easy to do.
  583.